<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BankCard extends Model
{
    protected $table = "c_bank_cards";

    /***
     * @param $filter
     * @return bool
     * 工作室绑定账号
     */
    public function add($filter)
    {
        $this->user_id = $filter['work_id'];
        $this->open_bank = $filter['open_bank'];
        $this->card_name = $filter['card_name'];
        $this->branch = $filter['branch'];
        $this->card_num = $filter['card_num'];
        $this->person_type = 2;
        return $this->save();
    }

    /***
     * @param $filter
     * 绑定账号详情
     */
    public function detail($filter)
    {
        $res = $this->where([['user_id', '=', $filter['work_id']], ['person_type', '=', 2]])->first();
        if (!empty($res)) {
            return $res->toArray();
        }
        return [];
    }
}
